package com.mysqldemo.controller;

import com.mysqldemo.entity.vo.ResponseVO;
import com.mysqldemo.entity.vo.PaginationResultVO;
import com.mysqldemo.entity.po.Info;
import com.mysqldemo.entity.query.InfoQuery;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import com.mysqldemo.service.InfoService;
import java.util.List;
/**
 * @Description Controller
 * @Author 徐大勇
 * @Version 1.8.0_131
 * @date 2023/07/06
 */

@RestController
@RequestMapping("/info")
public class InfoController  extends ABaseController{
	@Resource
	private InfoService infoService;
	//新增
	@RequestMapping("add")
	public ResponseVO add( Info info){
		infoService.add(info);
		return getSuccessResponseVO(null);
	}
	//根据条件分页查询
	@RequestMapping("loadDateList")
	public ResponseVO loadDateList( InfoQuery  query){
		return getSuccessResponseVO(infoService.findListByPage(query));
	}
	//批量新增
	@RequestMapping("addBatch")
	public ResponseVO addBatch(@RequestBody List<Info> listBatch){
		infoService.addBatch(listBatch);
		return getSuccessResponseVO(null);
	}
	//批量新增/更新
	@RequestMapping("addOrUpdateBatch")
	public ResponseVO addOrUpdateBatch(@RequestBody List<Info> listBatch){
		infoService.addOrUpdateBatch(listBatch);
		return getSuccessResponseVO(null);
	}

	//通过UserId查询
	@RequestMapping("getUserId")
	public ResponseVO getUserId(  String userId) {
		return getSuccessResponseVO(infoService.getByUserId(userId));
	}

	//通过UserId修改
	@RequestMapping("updateUserId")
	public ResponseVO updateUserId( Info bean , String userId) {
		infoService.updateByUserId(bean,userId);
		return getSuccessResponseVO(null);
	}

	//通过UserId删除
	@RequestMapping("deleteUserId")
	public ResponseVO deleteUserId(String userId) {
		infoService.deleteByUserId(userId);
		return getSuccessResponseVO(null);
	}

}
